<script lang="ts" setup>
import type { MedicalOrderList } from '@/types/order'
defineProps<{ item: MedicalOrderList }>()
</script>

<template>
  <div class="order-cart" v-for="i in item" :key="i.id">
    <div class="head">
      <div class="orderNo">
        订单号：{{ i.orderNo }}
      </div>
      <div class="status" v-if="i.status === 10">
        待支付
      </div>
      <div class="status" v-if="i.status === 11">
        待发货
      </div>
      <div class="status" v-if="i.status === 12">
        待收货
      </div>
      <div class="status" v-if="i.status === 13">
        已完成
      </div>
      <div class="status" v-if="i.status === 14">
        已取消
      </div>
    </div>
    <div class="main van-hairline--top" v-for="v in i.medicines" :key="v.id">
      <img :src="v.avatar">
      <van-tag>{{ v.prescriptionFlag ? '处方药' : '非处方药' }}</van-tag>
      <div class="info">
        <p class="name">
          <span>{{ v.name }}</span>
          <span ref="price">x {{ v.quantity }}</span>
        </p>
        <p class="size">
          <span>{{ v.specs }}</span>
        </p>
        <p class="price" ref="total">￥{{ v.amount }}</p>
      </div>
    </div>
    <div class="foot">
      <span>共计{{ i.medicines.length }}件商品</span>
    </div>
    <div class="btn">
      <van-button size="small" plain round>取消订单</van-button>
      <van-button v-if="i.status === 12" type="primary" size="small" plain round>确认收货</van-button>
      <van-button v-if="i.status === 10" type="primary" size="small" plain round>继续支付</van-button>
      <van-button v-if="i.status === 11" type="primary" size="small" plain round>催促发货</van-button>
      <van-button v-if="i.status === 13 || i.status === 14" type="primary" size="small" plain round>再次购买</van-button>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.order-cart {
  margin-top: 10px;
  padding: 10px 15px 0 15px;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  .head {
    display: flex;
    justify-content: space-between;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--cp-line);
    .orderNo {
      color: var(--cp-disable);
    }
    .status {
      color: var(--cp-orange);
    }
  }
  .main {
    display: flex;
    padding: 15px 0;
    position: relative;
    border-bottom: 1px solid var(--cp-line);
    .van-tag {
      position: absolute;
      left: 0;
      bottom: 12px;
      background-color: var(--cp-orange);
      vertical-align: middle;
    }
    img {
      width: 80px;
      // height: 80px;
      border-radius: 2px;
      overflow: hidden;
    }
    .info {
      padding-left: 15px;
      width: 100%;
      .name {
        display: flex;
        justify-content: space-between;
        font-size: 15px;
        margin-bottom: 5px;
        > span:first-child {
          width: 200px;
        }
        > span:last-child {
          width: 50px;
          text-align: right;
        }
      }
      .size {
        margin-bottom: 5px;
        .van-tag {
          background-color: var(--cp-primary);
          vertical-align: middle;
        }
        span:not(.van-tag) {
          margin-left: 10px;
          color: var(--cp-tag);
          vertical-align: middle;
        }
      }
      .price {
        font-size: 16px;
        color: #eb5757;
      }
    }
  }
  .foot {
    padding: 15px 4px;
    text-align: right;
    font-size: 12px;
    border-bottom: 1px solid var(--cp-line);
  }
  .btn {
    text-align: right;
    padding: 6px 0;
    .van-button {
      font-size: 10px;
    }
    .van-button:first-child {
      color: var(--cp-text3);
      margin-right: 10px;
    }
  }
}
</style>